// 所有路径
var hasPathSum = function(root, targetSum) {
    if(root==null) return false;
    if(root.left==null && root.right==null) return root.val==targetSum
    return hasPathSum(root.left,targetSum-root.val)|| hasPathSum(root.right,targetSum-root.val)
};
// 解法二
var hasPathSum = function(root, targetSum) {
    const sumarr = [];
    function Sum(root, partsum) {
        if (!root) return 0;
        partsum += root.val;
        if (!root.left && !root.right) {
            sumarr.push(partsum)
        }
        Sum(root.left, partsum)
        Sum(root.right, partsum)
    }
    Sum(root, 0);
    if (sumarr.indexOf(targetSum) !== -1) {
        return true
    }
    return false
};
